/*******************************************************************************
 * Copyright (c) 2008, 2009 Tapestry IDE Developers
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Tapestry IDE Developers - initial API and implementation
 *******************************************************************************/
package com.googlecode.tapestry.ide.core.model;

import java.util.EventObject;

/**
 * An element changed event describes a change to an element of the model.
 * <p>
 * This class is not intended to be instantiated or subclassed by clients.
 * Instances of this class are automatically created by the model.
 * </p>
 * 
 * @see IModelChangeListener
 */
public class ModelChangeEvent extends EventObject {

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/**
	 * The Enum Type.
	 */
	public enum Type {

		/** The ADDED. */
		ADDED,

		/** The REMOVED. */
		REMOVED,

		/** The CHANGED. */
		CHANGED
	};

	/** The type. */
	private Type type;

	/**
	 * Creates an new element change event.
	 * 
	 * @param element
	 *            the changed model element
	 * @param type
	 *            the type of modification (ADDED, REMOVED, CHANGED) this event
	 *            contains
	 */
	public ModelChangeEvent(IModelElement element, Type type) {
		super(element);
		this.type = type;
	}

	/**
	 * Returns the modified element.
	 * 
	 * @return the element
	 */
	public IModelElement getElement() {
		return (IModelElement) getSource();
	}

	/**
	 * Returns the type of modification.
	 * 
	 * @return the type
	 */
	public Type getType() {
		return type;
	}

}
